public class demo13 {
    public static void main(String[] args) throws InterruptedException {
        Thread t2= new Thread(()->{
            for (int i = 0; i < 4; i++) {
                System.out.println("t2");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }

            }
        });
        Thread t1 = new Thread(()->{
            //t1一进来就等待t2
            try {
                t2.join();
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            for (int i = 0; i < 3; i++) {
                System.out.println("t1");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }

            }
        });
        t1.start();
        t2.start();
        //main线程等待t1
        t1.join();
        System.out.println("end main");
    }
}
